import random
# 生成中奖号码
winning_numbers = []
while len(winning_numbers) < 8:
    num = random.randint(1, 33)
    if num not in winning_numbers:
        winning_numbers.append(num)
# 让用户输入数字
user_input = input("请输入8个数字，用空格隔开：")
user_numbers = user_input.split()
user_numbers = [int(num) for num in user_numbers]
# 比对中奖号码和用户输入号码
matched_count = 0
for num in user_numbers:
    if num in winning_numbers:
        matched_count += 1
# 输出结果
if matched_count == 8:
    print("恭喜你获得一等奖！")
elif matched_count == 7:
    print("恭喜你获得二等奖！")
elif matched_count == 6:
    print("恭喜你获得三等奖！")
elif matched_count == 5:
    print("恭喜你获得四等奖！")
else:
    print("很遗憾，你没有中奖。")
# 模拟随机购买10000注彩票对特定号码的中奖概率
target_numbers = [1, 3, 5, 7, 9, 11, 13, 15]
win_count = 0
for i in range(10000):
    winning_numbers = []
    while len(winning_numbers) < 8:
        num = random.randint(1, 33)
        if num not in winning_numbers:
            winning_numbers.append(num)
    matched_count = 0
    for num in target_numbers:
        if num in winning_numbers:
            matched_count += 1
    if matched_count >= 5:
        win_count += 1
print("模拟10000注彩票，其中{}注中奖，中奖概率为{:.2f}%。".format(win_count, win_count/100))
